<template>
  <!-- v-loading="true" -->
  <div>
    <div class="flex items-center pt-[20px] px-[20px]">
      <div class="text-[24px] font-semibold ">订单列表</div>
      <div @click="$router.push('/order')" class="ml-auto cursor-pointer" style="color: #6B7988;">全部订单&nbsp;&nbsp;></div>
    </div>
    <pageTable :tableData="tableData" :tableInit="params.tableInit" v-loading="loading">
      <template #orderstatu="{ row }">{{ filterOrder(row.orderstatu) }}</template>
      <template #price="{ row }">{{ moneyFormat(String(row.price), 3, '.', ',') }}</template>
    </pageTable>




  </div>
</template>

<script setup lang="ts">
import pageTable from "@/components/base-ui/page-table";

import { tableInit } from "./config/table.config";
import { usepageTable } from '@/components/base-ui/page-table/usePageTable'
import { getOrderList } from "@/api/order"

const emit = defineEmits(["compile"]);

const getRes = (q) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(
        {
          result: [
            {
              orderid: "1678006429",
              createTime: "1678006429",
              price: "3000",
              username: '张三',
              orderstatu: '1'
            },
            {
              orderid: "1678006429",
              createTime: "1678006429",
              price: "3000",
              username: '张三',
              orderstatu: '1'
            },
            {
              orderid: "1678006429",
              createTime: "1678006429",
              price: "300000",
              username: '张三',
              orderstatu: '1'
            },
            {
              orderid: "1678006429",
              createTime: "1678006429",
              price: "3000",
              username: '张三',
              orderstatu: '1'
            },
            {
              orderid: "1678006429",
              createTime: "1678006429",
              price: "3000",
              username: '张三',
              orderstatu: '1'
            },
          ],
          total: 4
        }
      )
    }, 1000)
  })
}

const {
  tableData,
  getData,
  params,
  loading,
  filterOrder,
  moneyFormat
} = usepageTable({
  tableInit,
  getRes: getOrderList,
})

getData()




</script>

<style scoped></style>
